{#include file="top.php"#}
<script type="text/javascript">
    function sidebar_newreport(uid,page){
        $.getJSON("/block.php?action=b16_1",{uid:uid,page:page},function(data){
           $('#sidebar_person_newreport').html(data.report);
        });
    }
    function showpop(text){
        $("#fullbg").fadeIn();
        $("#dialog1").fadeOut('slow');
        $("#dialog").fadeOut('slow');
        showLB('#dialog_popup',0);
        $("#popupText").text(text);
    }
    function closeLB(){
        $("#fullbg").fadeOut('slow');
        $("#dialog").fadeOut('slow');
        $("#dialog1").fadeOut('slow');
        $("#dialog_popup").fadeOut('slow');
    }

/*     function fb_recommend(sec,sid){
        $.getJSON("/product.php?action=ajax&t=12",{sec:sec,sid:sid},function(data){
            if(parseInt(data.recode)==1){
                $('#fb_recommend').html(data.likes);
            }else if(parseInt(data.recode)==2){
                $("#loginText").text("以iMORE帳戶登入");
                $("#login").attr("onClick","login('fb_recommend(\\'"+sec+"\\',"+sid+")')");
                $("#login_type").attr("onClick","fnblogin('fb_recommend(\\'"+sec+"\\',"+sid+")')");
                showLB('#dialog',0);
            }else{
                showpop(data.msg);
            }
        });
    } */


    function login(func){

        var email = $('#email').val();
        if($.trim(email).length==0){
            showpop("{#$NO_USERNAME#}");
            $('#email').focus();
            return false;
        }
        var password = $('#password').val();
        if($.trim(password).length==0){
            showpop("{#$NO_PASSWORD#}");
            $('#password').focus();
            return false;
        }
        /*
                var captcha = $('#captcha').val();
                if($.trim(captcha).length==0){
                        showpop("{#$ERR_CAPTCHA#}");
                        $('#captcha').focus();
                        return false;
                }
         */

        $.getJSON("/member.php?action=ajax_login_imore",{email:email,password:password/*,captcha:captcha*/},function(data){
            if(parseInt(data.ret)==1){
                showpop(data.msg);
            }else if(parseInt(data.ret)==2){
                showpop(data.msg);
                $('#captcha').attr("src","captcha.php?t="+Math.random());
            }else{closeLB();memberBar();eval(func);}
        });
    }

    function login_fnb(func){
        var email = $('#email').val();
        if($.trim(email).length==0){
            showpop("{#$NO_USERNAME#}");
            $('#email').focus();
            return false;
        }
        var password = $('#password').val();
        if($.trim(password).length==0){
            showpop("{#$NO_PASSWORD#}");
            $('#password').focus();
            return false;
        }
        /*
                var captcha = $('#captcha').val();
                if($.trim(captcha).length==0){
                        showpop("{#$ERR_CAPTCHA#}");
                        $('#captcha').focus();
                        return false;
                }
         */


        $.getJSON("/member.php?action=ajax_login_fnb",{email:email,password:password/*,captcha:captcha*/},function(data){
            if(parseInt(data.ret)==1){
                showpop(data.msg);
            }else if(parseInt(data.ret)==2){
                showpop(data.msg);
                $('#captcha').attr("src","captcha.php?t="+Math.random());
            }else{closeLB();memberBar();eval(func);}
        });
    }

    function fnblogin(func){
        $("#loginText").text("F&amp;B 會員登入 REGISTRATION");
        $("#login").attr("onClick","login_fnb("+func+")");
        $("#login_type_text").text("以 iMORE 登入");
        $("#login_type").attr("onClick","itriallogin("+func+")");
        $("#loginTextName").css("background-position","0 -940px");
        $("#classlogo").attr("class","itrial ir");

    }
    function itriallogin(func){
        $("#loginText").text("iTRIAL 會員登入 REGISTRATION");
        $("#login").attr("onClick","login("+func+")");
        $("#login_type_text").text("以 F&B 登入");
        $("#login_type").attr("onClick","fnblogin("+func+")");
        $("#loginTextName").css("background-position","0 -900px");
        $("#classlogo").attr("class","fabtn ir");

    }
    function showLB(ct,n){
        var sh=$(document).height();
        var sw=$(document).width();
        var st=$(window).scrollTop();
        var ch=$(window).height();
        var cw=$(window).width();
        var tbT=(Number(ch)/3+Number(st))+"px";
        var tbL=(Number(cw)/2)+"px";
        if(n==0){
            $("#fullbg").css({width:sw,height:sh});
            $(ct).css({top:tbT,left:tbL});
            $("#fullbg").fadeTo('slow', 0.4);
            $(ct).fadeIn('slow');
            $(window).scroll(function(){showLB(ct,1)});
            $(window).resize(function(){showLB(ct,1)});
        }else{
            if($("#fullbg").css("display")=="block"){
                $("#fullbg").css({width:sw,height:sh});
                $(ct).css({top:tbT,left:tbL});
            }
        }
    }
    function user_like(uid){
        $.getJSON("/person.php?action=ajax&t=1",{uid:uid},function(data){
            if(parseInt(data.recode)==2){
                $('#like_bt').html("<a href='javascript:void(0);' class='btn_grey' onclick='user_unlike("+uid+")'>取消關注</a>");
                $('#user_likes').text(parseInt($('#user_likes').text()) + 1);
            }else if(parseInt(data.recode)==1){
                $("#loginText").text("以iMORE帳戶登入");
                $("#login").attr("onClick","login('user_like("+uid+")')");
                $("#login_type").attr("onClick","fnblogin('user_like("+uid+")')");
                showLB('#dialog',0);
            }else{
                showpop(data.msg);
            }
        });
    }
    function user_unlike(uid){
        $.getJSON("/person.php?action=ajax&t=2",{uid:uid},function(data){
            if(parseInt(data.recode)==2){
                var l = parseInt($('#user_likes').html());
                $('#user_likes').html(l-1);
                $('#like_bt').html("<a  href='javascript:void(0);' class='btn_pink' onclick='user_like("+uid+")'>關注</a>");
            }else if(parseInt(data.recode)==1){
                $("#loginText").text("以iMORE帳戶登入");
                $("#login").attr("onClick","login('user_unlike("+uid+")')");
                $("#login_type").attr("onClick","fnblogin('user_unlike("+uid+")')");
                showLB('#dialog',0);
            }else{
                showpop(data.msg);
            }
        });
    }

</script>
<div class="body">
    <div class="main">
        <div class="u_box_top">
            <figure class="img_box">
                <img src="{#$user.photo_l#}"  width=77/>
            </figure>
            <strong class="name">{#$user.username#}</strong>
            <span class="btn_bk"><span id='user_likes'>{#$user.likes#}</span> Fans</span>
            {#if $uid neq $mid#}
            <span id='like_bt'>
                {#if $user.islike==0#}
                <a href="javascript:void(0);" class="btn_pink" onclick='user_like({#$user.id#})'>關注</a>
                {#else#}
                <a  href="javascript:void(0);" class="btn_grey" onclick='user_unlike({#$user.id#})'>取消關注</a>
                {#/if#}
            </span>
            {#/if#}
            <p>年齡 / {#$user.age#}</p>
            <p>臉部膚質 / {#$user.body_skin#}</p>
            <p>iTrial 分 / {#$user.points#}<a href="{#optimize_url('help', 'show','page=4')#}" target="_blank"><i class="icon point"></i></a></p>
        </div>
        <div class="list_row">
            <div class="tab_b_box tab_b_box_r">
                <a href="{#optimize_url('person', 'report','username='|cat:$user.username)#}">報告 / Blog</a>
                <a href="{#optimize_url('person', 'attention','ps=3&username='|cat:$user.username)#}" class="curr">關注會員</a>
                <a href="{#optimize_url('person', 'recommen','username='|cat:$user.username)#}">推介報告</a>
                <em class="line"></em>
            </div>
            {#if $t neq 2 && !empty($userlikes)#}
            <div class="hd_grey">已關注的會員</div>
            {#foreach  from=$userlikes item=v key=k#}
            <dl>
                <dt><a href="{#optimize_url('person', 'report','username='|cat:$v.username)#}" ><img src="{#$v.photo_l#}" width=77 /></a></dt>
                <dd>
                    <strong class="name"><a href="{#optimize_url('person', 'report','username='|cat:$v.username)#}" >{#$v.username#}</a></strong>
                    <p>{#if $v.reports_count#}{#$v.reports_count#}個報告{#/if#}{#if $v.reports_count && $v.recommen_count#} / {#/if#}{#if $v.recommen_count#}{#$v.recommen_count#}個推介報告{#/if#}</p>
                    <span class="s">{#if $v.member_type==5#}體驗達人{#else if $v.member_type==1#}試用專員{#else#}普通會員{#/if#}</span>
                </dd>
            </dl>
            {#/foreach#}
            {#if empty($t)#}
            {#if $attent_count1 > 3#}
            <p class="more_p"><a href="{#optimize_url('person', 'attention','t=1&ps=6&username='|cat:$user.username)#}" class="more">更多</a></p>
            {#/if#}
            {#else#}
            {#$pagelist1#}
            {#/if#}
            {#/if#}
            {#if $t neq 1 && !empty($likeusers)#}
            <div class="hd_grey">關注{#$user.username#}的會員</div>
            {#foreach  from=$likeusers item=v key=k#}
            <dl>
                <dt><a href="{#optimize_url('person', 'report','username='|cat:$v._name)#}" ><img src="{#$v.photo_l#}" width=77 /></a></dt>
                <dd>
                    <strong class="name"><a href="{#optimize_url('person', 'report','username='|cat:$v._name)#}">{#$v._name#}</a></strong>
                    <p>{#if $v.reports_count#}{#$v.reports_count#}個報告{#/if#}{#if $v.reports_count && $v.recommen_count#} / {#/if#}{#if $v.recommen_count#}{#$v.recommen_count#}個推介報告{#/if#}</p>
                    <span class="s">{#if $v.member_type==5#}體驗達人{#else if $v.member_type==1#}試用專員{#else#}普通會員{#/if#}</span>
                </dd>
            </dl>
            {#/foreach#}
            {#if empty($t)#}
            {#if $attent_count2 > 3#}
            <p class="more_p"><a href="{#optimize_url('person', 'attention','t=2&ps=6&username='|cat:$user.username)#}" class="more">更多</a></p>
            {#/if#}
            {#else#}
            {#$pagelist2#}
            {#/if#}
            {#/if#}
        </div>

    </div>
    <!-- main-->
    <div class="sidebar">

        {#show_block('b2',1,'','sidebar_ad')#}
        {#show_block('b1',2,'','sidebar_function')#}
        {#show_block('b3',0,'','sidebar_search')#}
        {#show_block('b16',0,'','sidebar_newreport','&uid='|cat:$user.id)#}
        {#show_block('b13',0,'','sidebar_registation')#}
        {#show_block('b9',0,'','sidebar_tutorial b_box')#}
        {#show_block('b6',0,'','sidebar_facebook')#}
    </div>
    <!-- sidebar -->

</div><!--body-->
<div id="fullbg" "></div>
<div  class="irpopbox popbox b_box" id="dialog" style="z-index: 60;	display:none;">
    <div class="hd">
        <h2 class="ir ht" id=loginTextName><span id=loginText>iTRIAL 會員登入 REGISTRATION</span></h2>
        <a class="popclose" style="cursor:pointer" onclick="closeLB();">close</a>
    </div>
    <div class="bd">
        <div class="lbox">
            <p>會員名稱 USERNAME</p>
            <input type="text" class="ipt" name="email" id="email">
            <p>密碼 PASSWORD</p>
            <input type="password" class="ipt" name="password" id="password">
            <a class="btn_s btn_s_login" onclick="login()" style="cursor:pointer" id="login"><strong>login</strong></a>
            <ul>
                <li><a href="/member.php?action=forgetPassword">忘記密碼</a></li>
                <li><a href="/member.php?action=reg&toURL={#$thisUrl#}">註冊新帳號</a></li>
            </ul>
        </div>
        <div class="rbox">
            <div class="lgbox"><em class="hack"></em>
                <a class="fbtn ir" href="/member.php?action=login_facebook&toURL={#$thisUrl#}"><strong>以facebook登入</strong></a><span><a class="fb_link" href="/member.php?action=login_facebook&toURL={#$thisUrl#}">以facebook登入</a></span>
            </div>
            <div class="lgbox lgbox2" onClick="fnblogin()" id=login_type style="cursor:pointer" ><em class="hack"></em>
                <a class="fabtn ir" id=classlogo><strong>以F&amp;B登入</strong></a><span id=login_type_text  >以F&amp;B登入</span>
            </div>
        </div>
    </div>
</div>
<div style="top:400px;z-index:60;display:none;" class="apopbox popbox b_box" id="dialog_popup">
    <div class="hd">
        <h2 class="ir ht"><span>提示信息 ALERT</span></h2>
        <a class="popclose" onclick="closeLB();" style="cursor:pointer">close</a>            </div>
    <div class="bd">
        <p id="popupText"></p>
        <a class="btn_b btn_s_im_back" href="javascript:void(0);" onclick="closeLB();"><strong>立即返回</strong></a>            </div>
</div>
{#include file="footer.php"#}